<?php
Yii::app()->clientScript->registerScript('cm-contact-grid', "
			var show_del_button = function(){
				var btn = this.getElementsByClassName('crud_del_button');
				btn[0].style.visibility = 'visible';
			}
			var hide_del_button = function(){
				var btn = this.getElementsByClassName('crud_del_button');
				btn[0].style.visibility = 'hidden';
			}
			var trs = document.getElementById('cm-contact-grid').getElementsByTagName('tr');
			var trs_count = trs.length;
			for (var i = 1; i < trs_count; i++) {
				trs[i].onmouseover = show_del_button;
				trs[i].onmouseout = hide_del_button;
			}
			
		", CClientScript::POS_READY);
?>
<?php
/* @var $this CmContactController */
/* @var $model CmContact */

//$this->breadcrumbs=array(
////	'Contacts'=>array('index'),
//	'Contact Manager',
//);

//$this->menu=array(
//	array('label'=>'List Contacts', 'url'=>array('index')),
//	array('label'=>'Create Contact', 'url'=>array('create')),
//);
//
//Yii::app()->clientScript->registerScript('search', "
//$('.search-button').click(function(){
//	$('.search-form').toggle();
//	return false;
//});
//$('.search-form form').submit(function(){
//	$('#cm-contact-grid').yiiGridView('update', {
//		data: $(this).serialize()
//	});
//	return false;
//});
//");
?>
<?php if(Yii::app()->user->hasFlash('success')): ?>
<div class="alert alert-success">
	<?php echo Yii::app()->user->getFlash('success'); ?>
</div>
<?php endif; ?> 
<!--
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php /*echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
));*/ ?>
</div> search-form -->
<!--<button onclick="window.location='<?php // echo $this->createAbsoluteUrl('create'); ?>'">Add</button>-->
<?php 
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'cm-contact-grid',
//	'dataProvider'=>$model->search(),
	'dataProvider'=>$dataProvider,
//	'filter'=>$model,
        'template' => '{items}{pager}',
        'pagerCssClass' => 'pager_wrapper',
        'pager' => array(
            'class' => 'CLinkPager',
            'header' => false,
			'nextPageLabel' => 'next',
			'prevPageLabel' => 'previous',			
            ),
	'columns'=>array(
		array(
			'header' => '',
			'type' => 'raw',
			'value' => '$row + 1'
		),
		'first_name' => array(
			'name' => 'first_name',
			'header' => 'First Name'
		),	
		'last_name' => array(
			'name' => 'last_name',
			'header' => 'Last Name'			
		),			
		'email' => array(
			'sortable' => false,
			'name' => 'email'
		),
		array(
			'name' => 'bestPhone',
			'header' => 'Cellular',
			'type' => 'raw',
			'value' => '$data->getBestPhone()'
		),
		array(
			'headerHtmlOptions' => array(
//				'colspan' => 2
			),
			'header' => 'Actions',
			'class'=>'CButtonColumn',
			'template' => '<div class="buttons-wrapper">{update}{view}<span class="crud_del_button">{delete}</span></div>',
                        'buttons' => array(
                            'update' => array(
                                'imageUrl' => false,
                                'label' => 'edit',
                                'options' => array(
                                    'class' => 'crud_button'
                                )
                            ),
                            'view' => array(
                                'imageUrl' => false,
                                'label' => 'view',
                                'options' => array(
                                    'class' => 'crud_button crud_last_button'
                                )
                            ),
                            'delete' => array(
                                'imageUrl' => false,
                                'label' => 'X',
                                'options' => array(
//                                    'class' => 'crud_del_button',
									'title' => 'delete',
                                )
                            )
                        )
		),
	),
	'ajaxUpdate' => false,
//	'pager' => array(
//		'class' => 'CLinkPager',
//		'pageSize' => 2
//	)
)); ?>
<!--<button onclick="window.location='<?php // echo $this->createAbsoluteUrl('create'); ?>'">Add</button>-->
